try:
    s = eval(input())
    b = []
    if s > 0 and s <= 100:
        for i in range(s):
            x = input().split()
            y = (float(x[2]) + float(x[3]) + float(x[4])) / 3
            x.append(y)
            b.append(x)
        b = sorted(b, key=lambda x: -int(x[2]))
        b = sorted(b, key=lambda x: -x[5])
        for j in b:
            print("%s %s %s %s %s %.2f" % (j[0], j[1], j[2], j[3], j[4], float(j[5])))
    else:
        print("输入的人数必须是数字,大于0并且小于等于100")
except:
    print("输入的人数必须是数字,大于0并且小于等于100")
